<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //解构数组 | 字符串 ->  值的集合都可以进行结构
        //数组解构 -> [] <- 字符串
        //1. 基本的数组结构 
        let [a,b,c] =  [1,2,3];
        console.log(a,b,c);
        // let a =  arr[1];
        // let b =  arr[2];
        // let c =  arr[3];
        //2.嵌套数组解构
        let [d,[e],f] = [1,[2],3]
        console.log(d,e,f);
        //3.忽略数组解构
        let [g,,i]=[1,2,3];
        console.log(g,i);
        //4.解构数组和默认值
        let [aa,bb,cc = 3] = [1,2];
        console.log(aa,bb,cc);
        //5.解构数组数据
        //...获取剩余的所有 返回值是一个数组
        //...只能在最后出现
        let [aaa,bbb,...ccc] = [1,2,3,4,5,6]
        console.log(aaa,bbb,ccc);
        //6.解构字符串 -> 获取字符
        let [aaaa,bbbb,cccc,dddd] = "abcd";
        console.log(aaaa);

    </script>
</body>
</html>